package com.fms.fmsapi.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fms.fmsapi.common.ResponseEnum;
import com.fms.fmsapi.common.config.WxConfig;
import com.fms.fmsapi.entity.R;
import com.fms.fmsapi.service.UserService;
import com.fms.fmsapi.utils.FetchGet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import com.fasterxml.jackson.core.type.TypeReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/auth")
public class AuthController {

    @Autowired
    UserService userService;

    @GetMapping("/login")
    public R login(String code,String nickname){
        System.out.println(code);
        System.out.println(nickname);
        Map<String, String> login = userService.login(code, nickname);
        if(login!=null){
            return R.success(login);
        } else {
            return R.fail(ResponseEnum.USER_LOGIN_ERROR);
        }
    }

    @GetMapping("/test")
    public R test(){
        return R.success(userService.list());
    }


}
